<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>留言列表</title> 
    <link rel="shortcut icon" href="/favicon.ico"> 
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <base target="_blank">
<!-- 全局js -->
<script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
<script src="/public/admin/js/plugins/layer/layer.min.js"></script> 
<!-- 自定义js -->
<script src="/public/admin/js/content.js?v=1.0.0"></script>
<script src="/public/admin/js/contabs.js"></script>
<script src="/public/admin/js/common.js"></script>
<script src="/public/admin/js/article.js"></script> 

<!-- Bootstrap table -->
<script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/public/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>    
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>留言列表</h5> 
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <div class="panel-body">
                                        <div>
                                            <a style="display:none;" onclick="openYemian('/index.php/Admin/Message/addmessage','添加留言')" href="javascript:;" class="btn btn-primary"><i class="fa fa-plus"></i>新增</a>
                                            <a onclick="javascript:window.location.href=location.href;" href="javascript:;" class="btn btn-primary"><i class="glyphicon glyphicon-refresh"></i>刷新</a>
                                        </div>
                                    </div>                  
                                </div><!-- /.box-header -->
                                <div class="box-body">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div id="ajaxList">
                                            <form method="post" enctype="multipart/form-data" id="form-order">
                                                    <table class="table table-bordered">
                                                        <thead>
                                                            <tr>
                                                                <th style="width: 1px;"><input type="checkbox" onclick="$('input[name*=\'ids\']').prop('checked', this.checked);"></th>
                                                                <th>ID</th>
                                                                <th>姓名</th>
                                                                <th>学号</th>
                                                                <th>内容</th>
                                                                <th>留言时间</th>
                                                                <th>留言状态</th>
                                                                <th>回复状态</th>
                                                                <th>操作</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody id="ajaxList">
                                                            {if empty($list)}
                                                                <tr role="row">
                                                                    <td colspan="9" align="center">暂无数据</td>
                                                                </tr>
                                                            {/if}
                                                            {foreach name="list" item="vo" key="k" }
                                                              <tr role="row">
                                                                <td><input type="checkbox" name="ids[]" value="{$vo.id}"></td>
                                                                <td>{$vo.id}</td>
                                                                <td>{$vo.nick_name}{if $vo['is_read'] == 0}<span style="color:red;">(未读)</span>{/if}</td>
                                                                <td>{$vo.user_name}</td>
                                                                <td><span title="{$vo.content}">{$vo.content|getSubstr=0,33}</span></td>
                                                                <td>{$vo.add_time|date='Y-m-d H:i:s'}</td>
                                                                <td>{if $vo['is_read']} 已读 {else/} 未读{/if}</td>
                                                                <td>{empty name="vo.reply"} 未回复 {else/} 已回复 {/empty}</td>
                                                                <td>
                                                                  <a class="btn btn-primary" href="javascript:;" title="查看" onclick="openYemian('/index.php/Admin/Message/msgRead/id/{$vo.id}','查看留言')"><i class="fa fa-eye"></i></a>
                                                                  <a class="btn btn-danger" href="javascript:void(0)" title="删除" onclick="delarticle(this,'确定删除该留言？此操作不可恢复！',{$vo.id},'/index.php/Admin/Message/msgDel')"><i class="fa fa-trash-o"></i></a>
                                                                </td>
                                                              </tr>
                                                            {/foreach}
                                                        </tbody>
                                                    </table>
                                                </form>
                                            <div>
                                               <div style="float:left;"><a href="javascript:void(0);" onclick="delselect()" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="删除">删除选中</a></div>
                                                <div style="float:right;margin-top:-20px;" id="pagelist">{$page|raw}<span style="float:right;margin:25px">共{$total}条</span></div>
                                            </div>
                                            <script>
                                                // 点击分页触发的事件
                                                $(".pagination li").removeClass('disabled');
                                                $(".pagination  a").click(function(){
                                                    cur_page = $(this).data('p');
                                                    $(this).attr('href');
                                                    if ($(this).attr('href') != '#'){
                                                        window.location.href = $(this).attr('href');
                                                    }
                                                    return false;
                                                });
                                                
                                            </script>                                                
                                            </div>
                                        </div>
                                    </div>
                                </div> <!-- /.box-body -->
                           </div><!-- /.box -->
                        </div>
                   </div>
                </div>
            </div>
        </div>
    </div> 
</div> 


<input id="handle_status" value="" hidden="hidden">
<script>

function delarticle(obj,name,id,url) {
    top.layer.confirm(name,{
        icon : 3,
        btn:['确定','取消'],
    } , function(){
        $.ajax({
            url : url,
            type : "post",
            data : {id:id,act:'del'},
            dataType : "json",
            success:function(data){
                if (data.status == 0) { 
                    top.layer.msg(data.message);
                } else {
                    top.layer.msg(data.message);
                    $(obj).parent().parent().remove();
                    var total = $("#total").html()-1;
                    $("#total").html(total);
                }
            }
        });
    } , function(){
        layer.close(); //再执行关闭 
    })
} 

// 删除选中
function delselect(){
    parent.layer.confirm('确定要删除选中吗？', function(){
        url = window.location.href;
        $.ajax({
            url:"/index.php/Admin/message/delselect",
            data : $('#form-order').serialize(),
            success: function(v){
                var v =  eval('('+v+')');
                parent.layer.msg(v.message, {icon: v.icon,time: 1000});
                if(v.status == 1){
                    window.location = window.location;
                }
                // if(v.hasOwnProperty('status') && (v.status == 1))
                //     getAjaxList('ajaxList',1,"/index.php/Admin/Article/ajaxArticleList");
            }
        });
    });
}

</script>

</body>

</html>